#pragma once

#include "SRNLUTypeDef.h"
#include <map>
#include <string>
#include <set>

class HybridSRCondition
{
public:
	HybridSRCondition(void);
	~HybridSRCondition(void);

	inline std::map<std::string, std::string> getCondPairs(void) {	return m_condPairs;			}
	inline void addCondition(std::string key, std::string value) {	m_condPairs[key] = value;	}

private:
	std::map<std::string, std::string> m_condPairs;
};

typedef enum {
	HYBRID_SR_SYNC_WAIT_ALL,
	HYBRID_SR_SYNC_WAIT_BY_TIME,
	HYBRID_SR_SYNC_WAIT_BY_ENGINE,
	HYBRID_SR_SYNC_SKIP_OTHERS,
	HYBRID_SR_SYNC_UNKNOWN
} HYBRID_SR_SYNC_STRATEGY_TYPE;

static const char* HybridSyncStrategyTypeStrings[] = {
	"waitForAll",
	"waitByTime",
	"waitByEngine",
	"skipOthers",
	"Unknown"
};

static const HYBRID_SR_SYNC_STRATEGY_TYPE getHybridSyncStrategyType(std::string str) {
	if (equalsIgnoreCase(str, "waitForAll"))	return HYBRID_SR_SYNC_WAIT_ALL;
	if (equalsIgnoreCase(str, "waitByTime"))	return HYBRID_SR_SYNC_WAIT_BY_TIME;
	if (equalsIgnoreCase(str, "waitByEngine"))	return HYBRID_SR_SYNC_WAIT_BY_ENGINE;
	if (equalsIgnoreCase(str, "skipOthers"))	return HYBRID_SR_SYNC_SKIP_OTHERS;
	return HYBRID_SR_SYNC_UNKNOWN;
}

static const std::string getHybridSyncStrategyTypeStrings(HYBRID_SR_SYNC_STRATEGY_TYPE type) {
	return HybridSyncStrategyTypeStrings[type];
}

typedef enum {
	HYBRID_SR_POST_PROC_ADD_ALL,
	HYBRID_SR_POST_PROC_NORM_CONF,
	HYBRID_SR_POST_PROC_MERGE,
	HYBRID_SR_POST_PROC_UNKNOWN
} HYBRID_SR_POST_PROC_STRATEGY_TYPE;

static const char* HybridPPStrategyTypeStrings[] = {
	"addAll",
	"normConf",
	"align",
	"Unknown"
};

static const HYBRID_SR_POST_PROC_STRATEGY_TYPE getHybridPostProcSyncStrategyType(std::string str) {
	if (equalsIgnoreCase(str, "addAll"))	return HYBRID_SR_POST_PROC_ADD_ALL;
	if (equalsIgnoreCase(str, "normConf"))	return HYBRID_SR_POST_PROC_NORM_CONF;
	if (equalsIgnoreCase(str, "align"))		return HYBRID_SR_POST_PROC_MERGE;
	return HYBRID_SR_POST_PROC_UNKNOWN;
}

static const std::string getHybridPostProcStrategyTypeStrings(HYBRID_SR_POST_PROC_STRATEGY_TYPE type) {
	return HybridPPStrategyTypeStrings[type];
}

class HybridSRStrategy
{
public:
	HybridSRStrategy(void);
	~HybridSRStrategy(void);

	inline HybridSRCondition*					getCondition()				{ return &m_condition;					}
	inline void addCondition(std::string key, std::string value)			{ m_condition.addCondition(key, value);	}
	
	inline std::set<SREngineType>				getEngines()				{ return m_Engines;						}
	inline void addEngine(SREngineType type)								{ m_Engines.insert(type);				}
	inline bool isEngineIncluded(SREngineType type)							{ return m_Engines.find(type) != m_Engines.end();}
	
	inline HYBRID_SR_SYNC_STRATEGY_TYPE			getSyncStrategy()			{ return m_syncStrategy;				}
	inline void setSyncStrategy(HYBRID_SR_SYNC_STRATEGY_TYPE type)			{ m_syncStrategy = type;				}
	
	inline int									getSyncWaitTime()			{ return m_syncWaitTime;				}
	inline void setSyncWaitTime(int time)									{ m_syncWaitTime = time;				}

	inline SREngineType							getSyncWaitEngine()			{ return m_syncWaitEngine;				}
	inline void setSyncWaitEngine(SREngineType engine)						{ m_syncWaitEngine = engine;			}

	inline float								getSyncSkipConf()			{ return m_syncSkipConf;				}
	inline void setSyncSkipConf(float conf)									{ m_syncSkipConf = conf;				}

	inline HYBRID_SR_POST_PROC_STRATEGY_TYPE	getPostProcStrategy()		{ return m_postProcStrategy;			}
	inline void setPostProcStrategy(HYBRID_SR_POST_PROC_STRATEGY_TYPE type) { m_postProcStrategy = type;			}

	inline int									getPostProcMaxNum()			{ return m_postProcMaxNum;				}
	inline void setPostProcMaxNum(int num)									{ m_postProcMaxNum = num;				}

	inline float								getPostProcMinConf()		{ return m_postProcMinConf;				}
	inline void setPostProcMinConf(float conf)								{ m_postProcMinConf = conf;				}

private:
	HybridSRCondition					m_condition;

	std::set<SREngineType>				m_Engines;

	HYBRID_SR_SYNC_STRATEGY_TYPE		m_syncStrategy;
	int									m_syncWaitTime;
	SREngineType						m_syncWaitEngine;
	float								m_syncSkipConf;

	HYBRID_SR_POST_PROC_STRATEGY_TYPE	m_postProcStrategy;
	int									m_postProcMaxNum;
	float								m_postProcMinConf;
};

